#ifndef __SELF_UPDATE_H__
#define __SELF_UPDATE_H__

#include <windows.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef enum SU_REPLIES
{
    surUndetermined = 0,
    surYes,
    surNo,
    surCancel,
    surHelp,
} SU_REPLIES;

#define MAX_URL_LENGTH 320

typedef struct SELFUPDATEPARAM SELFUPDATEPARAM;

typedef void (*SELFUPDATE_CALLBACK)(SELFUPDATEPARAM* Param);

typedef struct SELFUPDATEPARAM
{
	void* User;
	wchar_t* InfoUrl;
	int VersionCode;
	wchar_t* AppName;
	wchar_t Homepage[MAX_URL_LENGTH];
	wchar_t UpdateFilePath[MAX_URL_LENGTH];
	wchar_t UpdateFileName[MAX_URL_LENGTH];
	wchar_t UpdateLogFileName[MAX_URL_LENGTH];
	wchar_t DownloadPage[MAX_URL_LENGTH];
	BOOL UpdateFound;
    SU_REPLIES AnswerAllowUpdate;
    SU_REPLIES AnswerExitRunningApp;
	SELFUPDATE_CALLBACK OnUpdateNotFound;
	SELFUPDATE_CALLBACK OnUpdateFound;
	SELFUPDATE_CALLBACK OnDownloaded;
} SELFUPDATEPARAM;

void SelfUpdate(SELFUPDATEPARAM* Param);

char* GetContentFromUrl(const wchar_t* Url, BOOL ToString, DWORD* Length);

wchar_t* GetFileNameOffsetW(wchar_t* FullName);

#ifdef __cplusplus
}
#endif

#endif